﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OracleClient;
using System.Data;
using BookingSystemDAL;
using BookingSystemModel;
using BookingSystemBLL;


public partial class UserLookupFlight : System.Web.UI.Page
{
    //FlightBLL mahua = new FlightBLL();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindData();
        }
    }

    public void BindData()
    {
        GridView_lookup.AllowPaging = true;//是否启用分页
        GridView_lookup.PageSize = 10;//每页显示条数
        DataSet dataset =FlightBLL.GetAllFlight();
        this.GridView_lookup.DataSource = dataset.Tables[0];
        this.GridView_lookup.DataBind();//绑定数据源
        if (GridView_lookup.PageIndex == 0)
        {
            this.LinkButton1.Enabled = false;
            this.LinkButton2.Enabled = false;
        } 
        else
        {
            this.LinkButton1.Enabled = true;
            this.LinkButton2.Enabled = true;
        }

        if (GridView_lookup.PageIndex == GridView_lookup.PageCount-1)
        {
            this.LinkButton3.Enabled = false;
            this.LinkButton4.Enabled = false;
        } 
        else
        {
            this.LinkButton3.Enabled = true;
            this.LinkButton4.Enabled = true;
        }
    }
   
    protected void GridView_lookup_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        GridView_lookup.PageIndex = e.NewPageIndex;
        BindData();
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        switch (((LinkButton)sender).CommandArgument.ToString())
        {
            //将不同CommandArgument参数  而同一CommandName名字的4个按钮 循环取CommandArgument参数 利用索引进行判断
            //从而实现分页功能 注意的一点是 4个 按钮必须要触发同一个  单击事件
            case "first":
                GridView_lookup.PageIndex = 0;
                break;
            case "last":
                GridView_lookup.PageIndex = GridView_lookup.PageCount - 1;
                break;
            case "prev":
                GridView_lookup.PageIndex = GridView_lookup.PageIndex - 1;
                break;
            case "next":
                GridView_lookup.PageIndex = GridView_lookup.PageIndex + 1;
                break;

        }
        //之后 重新绑定
        DataBind();
    }
    protected void Search_Click(object sender, EventArgs e)
    {

    }
}